/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package it.txt.access.capability.libraries.rabbitmq.tester;

import it.txt.access.capability.libraries.rabbitmq.exception.AbstractApplicationException;
import it.txt.access.capability.libraries.rabbitmq.impl.publisher.PublisherApplication;
import it.txt.access.capability.libraries.rabbitmq.impl.subscriber.SubscriberApplication;
import it.txt.access.capability.libraries.rabbitmq.settings.PublisherSettings;
import it.txt.access.capability.libraries.rabbitmq.settings.SubscriberSettings;
import java.io.IOException;

/**
 *
 * @author seccia
 */
public class RabbitMQLibTester {

    //private static final String confPath = "D:\\Developing\\NetBeans\\Maven2Projects\\TXTAccess\\TXTAccess_BIN\\etc\\AbstractConnections.conf";

    public static void main(String[] args) throws Exception{
        //RabbitMQLibTester.testSubscriberApplication();
        RabbitMQLibTester.testPublisherApplication();
    }

    private static void testSubscriberApplication() throws AbstractApplicationException, InterruptedException, IOException{
        SubscriberSettings settings = (SubscriberSettings)SettingLoader.loadGuestSettings();
        //String namespace = "amqp://service.rabbitmq/ENS?Namespace=Mirafiori%20Robots&Pattern=PLine1.%23.Robots.*";
        SubscriberApplication subscriberApplication = new SubscriberApplication(settings);
        subscriberApplication.connect();
        subscriberApplication.basicSubscribe();
    }

    private static void testPublisherApplication() throws AbstractApplicationException, InterruptedException, IOException{
        PublisherSettings settings = (PublisherSettings)SettingLoader.loadGuestSettings();
        //String namespace = "amqp://service.rabbitmq/ENS?Namespace=Mirafiori%20Robots&Pattern=PLine1.Cell2.Robots.Rb2";
        PublisherApplication publisher = new PublisherApplication(settings);
        publisher.connect();
        int i = 1;
        publisher.basicPublish("Cristofer Publishing Ciao: " + i);
        i++;
        publisher.basicPublish("Cristofer Publishing Ciao: " + i);
        i++;
        publisher.basicPublish("Cristofer Publishing Ciao: " + i);
        i++;
        publisher.basicPublish("Cristofer Publishing Ciao: " + i);
        i++;
        publisher.basicPublish("Cristofer Publishing Ciao: " + i);
        publisher.disconnect();
    }
}
